package cn.huapu.power.energy.service.impl;

import cn.huapu.power.energy.bean.Clientpowerst;
import cn.huapu.power.energy.bean.Clntpwrsourcet;
import cn.huapu.power.energy.bean.bo.DateParameterBo;
import cn.huapu.power.energy.bean.vo.*;
import cn.huapu.power.energy.mapper.ClientpowerstMapper;
import cn.huapu.power.energy.mapper.ClntpwrsourcetMapper;
import cn.huapu.power.energy.service.ClntpwrsourcetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 测试用户权限服务实现类
 * @author autogen
 *
 */
@Service
public class ClntpwrsourcetServiceImpl extends BaseServiceImpl<ClntpwrsourcetMapper, Clntpwrsourcet,Integer> implements ClntpwrsourcetService {

    @Autowired
    private ClntpwrsourcetMapper clntMapper;
    @Autowired
    private ClientpowerstMapper clientpowerstMapper;
    



    @Override
    @Transactional(readOnly = true)
    public ClntPowerVo getTotle(String year,String month,String year1,String month1,int id) {
        ClntPowerVo clntPowerVo = clntMapper.getTotle(year,month,year1,month1,id);
        return clntPowerVo;
    }

    @Override
    @Transactional(readOnly = true)
    public PowerFessZBVo getElectTityZb(DateParameterBo dateParameterBo) {
        PowerFessZBVo powerFessZBVo = clntMapper.getElectTityZb(dateParameterBo);
        return powerFessZBVo;
    }

    @Override
    @Transactional(readOnly = true)
    public List<EcectCollectionVo> electCollection(DateParameterBo da) {
        List<EcectCollectionVo> ecectCollectionVos = clntMapper.electCollection(da);
        return ecectCollectionVos;
    }

    @Override
    @Transactional(readOnly = true)
    public Map<String, Object> getElectDistr(DateParameterBo da) {
        List<ElectFormVo> elecYear = clntMapper.getElectDistr(da);
        da.setMonth("1");
        List<ElectFormVo> elecMonth = clntMapper.getElectDistr(da);
        da.setDay("1");
        List<ElectFormVo> elecDay = clntMapper.getElectDistr(da);
        Map<String,Object> map = new LinkedHashMap<>();
        map.put("elecYear",elecYear);
        map.put("elecMonth",elecMonth);
        map.put("elecDay",elecDay);
        return map;
    }

    @Override
    @Transactional(readOnly = true)
    public ClientpowerstVo getReadTime(DateParameterBo da) {
        ClientpowerstVo clVo = clntMapper.getReadTime(da);
        return clVo;
    }

    @Override
    @Transactional(readOnly = true)
    public ClntPowerVo getReadPower(String date, String date1, int id) {
        ClntPowerVo clnt1 = clntMapper.getReadPower(date,date1,id);
        return clnt1;
    }

    @Override
    @Transactional(readOnly = true)
    public LocalDateTime getLastDate(DateParameterBo da) {
    	Clientpowerst bean = clientpowerstMapper.getMaxTime(da.getId());
    	if(bean!= null) {
    		return bean.getTime();
    	}       
        return null;
    }

    @Override
    @Transactional(readOnly = true)
    public List<ClntPowerVo> getDateAndClntcj(String dateOne, String dateTwo,int id) {
        List<ClntPowerVo> clnt =  clntMapper.getDateAndClntcj(dateOne,dateTwo,id);
        return clnt;
    }

    @Override
    @Transactional(readOnly = true)
    public List<ClntPowerVo> getCycleFess(DateParameterBo da) {
        List<ClntPowerVo> clnts = clntMapper.getCycleFess(da);
        return clnts;
    }

    @Override
    @Transactional(readOnly = true)
    public List<ClntPowerVo> getElectFessZB(DateParameterBo da) {
        List<ClntPowerVo> clnts = clntMapper.getElectFessZB(da);
        return clnts;
    }
}
